package org.example.back.controller.Forum;


import org.example.back.service.Forum.ForumPostLikeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/forum/posts")
public class ForumPostLikeController {

    @Autowired
    private ForumPostLikeService likeService;

    @PostMapping("/{postId}/like")
    public String toggleLike(@PathVariable Long postId, @RequestParam int userId) {
        boolean liked = likeService.toggleLike(postId, userId);
        return liked ? "Liked" : "Unliked";
    }

    @GetMapping("/{postId}/likes")
    public int getLikeCount(@PathVariable Long postId) {
        return likeService.getLikeCount(postId);
    }
}
